<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949.46">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #6c2a2a}
p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; min-height: 17.0px}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #082cb0}
span.s3 {color: #6c2a2a}
span.s4 {color: #000000}
span.s5 {font: 10.0px Monaco}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>BFDecode1<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b></span><b>3D Ambisonic decoder</b></p>
<p class="p2"><br></p>
<p class="p3"><b>BFDecode1.ar(w, x, y, z, azimuth, elevation, wComp)</b></p>
<p class="p4"><br></p>
<p class="p3">Decode a two dimensional ambisonic B-format signal for any speaker arrangement</p>
<p class="p3"><b>w, x, y, z</b> - the B-format signals. All of these MUST be audio rate signals. If you want to zero one out, use</p>
<p class="p3"><span class="Apple-tab-span">	</span>K2A.ar(0).</p>
<p class="p3"><b>azimuth</b> - the angle from 0pi front and center of the speaker.<span class="Apple-converted-space">  </span>Can be an array of angles.</p>
<p class="p3"><b>elevation </b>- the angle from 0pi center of the speaker.<span class="Apple-converted-space">  </span>Can be an array of angles.</p>
<p class="p3"><b>wComp</b> - chooses how the W channels is scaled. If 0, a scaler of 0.707 is used. If 1, W is varied according to the scaling of the X, Y and Z channels. 1 is the default.</p>
<p class="p4"><br></p>
<p class="p4"><br></p>
<p class="p3">Because of the way the W component is scaled, it is recommended that you only decode with BFEncode signals with BFDecode1 and it's methods.</p>
<p class="p4"><br></p>
<p class="p3">s=Server.internal.boot;</p>
<p class="p5">(</p>
<p class="p5">{</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> w, x, y, z, p, a, b, c, d;</p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p5"><span class="Apple-tab-span">	</span>p = <span class="s2">PinkNoise</span>.ar; <span class="s3">// source</span></p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p7"><span class="s4"><span class="Apple-tab-span">	</span></span>// B-format encode</p>
<p class="p5"><span class="Apple-tab-span">	</span>#w, x, y, z = <span class="s2">BFEncode1</span>.ar(p, MouseX.kr(-pi, pi), MouseY.kr(0.25pi, -0.25pi), 1);<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p7"><span class="s4"><span class="Apple-tab-span">	</span></span>// B-format decode to cube / quad ([lfh, rfh, rrh, lrh, lfl, rfl, rrl, lrl])</p>
<p class="p7"><span class="Apple-tab-span">	</span>// lfl = left fron high, lfl = left front low etc...</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">BFDecode1</span>.ar(w, x, y, z,<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[-0.25pi, 0.25pi, 0.75pi, 1.25pi,-0.25pi, 0.25pi, 0.75pi, 1.25pi],<span class="Apple-converted-space"> </span></p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>[0.25pi,0.25pi,0.25pi,0.25pi,-0.25pi,-0.25pi,-0.25pi,-0.25pi,]);</p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p5">}.scope(8);</p>
<p class="p5">)</p>
<p class="p6"><br></p>
<p class="p1"><b>3D Ambisonic decoder with compensation for speakers at different distances (delay and intenisty caluclated for meters)</b></p>
<p class="p8"><br></p>
<p class="p8"><br></p>
<p class="p6"><br></p>
<p class="p3"><b>BFDecode1.ar1(w, x, y, z, azimuth, elevation, maxDist, distance)</b></p>
<p class="p4"><br></p>
<p class="p3">Decode a two dimensional ambisonic B-format signal for any speaker arrangement</p>
<p class="p3"><b>w, x, y, z</b> - the B-format signals.<span class="Apple-converted-space"> </span></p>
<p class="p3"><b>azimuth</b> - the angle from 0pi front and center of the speaker.<span class="Apple-converted-space">  </span>Can be an array of angles.</p>
<p class="p3"><b>elevation </b>- the angle from 0pi center of the speaker.<span class="Apple-converted-space">  </span>Can be an array of angles.</p>
<p class="p3"><b>maxDist - </b>the distance (in meters) to the furthest speaker from center (this allocates the delay size)</p>
<p class="p3"><b>distance</b> - the distance (in meteres) to each speaker.</p>
<p class="p3"><b>scaleflag</b> - if 1, apply amplitude scaling to the closest signals to match more distant speakers</p>
<p class="p4"><br></p>
<p class="p3">s=Server.internal.boot;</p>
<p class="p5">(</p>
<p class="p5">{</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">var</span> w, x, y, z, p;</p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p5"><span class="Apple-tab-span">	</span>p = PinkNoise.ar(1) * <span class="s2">LFSaw</span>.kr(2, pi, -0.2, 0.2);<span class="s5"> </span><span class="s3">// source</span></p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p7"><span class="s4"><span class="Apple-tab-span">	</span></span>// B-format encode</p>
<p class="p5"><span class="Apple-tab-span">	</span>#w, x, y, z = <span class="s2">BFEncode1</span>.ar(p, MouseX.kr(-0.5pi, 0.5pi), 0, 1);<span class="Apple-converted-space"> </span></p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p7"><span class="s4"><span class="Apple-tab-span">	</span></span>// B-format decode to stereo with speakers at different distances</p>
<p class="p5"><span class="Apple-tab-span">	</span><span class="s2">BFDecode1</span>.ar1(w, x, y, z, [-0.25pi, 0.25pi], 0, 10, [MouseY.kr(5, 10), 10]);</p>
<p class="p6"><span class="Apple-tab-span">	</span></p>
<p class="p5">}.scope(2);</p>
<p class="p5">)</p>
</body>
</html>
